import { COMMENT_LIST_DATA } from '../actions/actionType'
const initState = {
  commentData: {},
  commentList: []
}
const getCommentData = (state, action) => {
  let list = [];
  if (state.commentList.length > 0) {
    list = state.commentList.concat(action.obj.data.comments);
  } else {
    list = action.obj.data.comments;
  }
  return { ...state, commentData: action.obj.data, commentList: list }
}

const menuReducer = (state = initState, action) => {
  switch (action.type) {
    case COMMENT_LIST_DATA:
      return getCommentData(state, action)
    default:
      return state
  }
}
export default menuReducer
